﻿//创建时间: 2010-11-22
//创建作者: 李 城
//功能说明: 发布引擎详细操作
//最后修改: 2010-11-22 
using System;
using System.Collections.Generic;
using System.Text;

using TRPOP.Common;
using TRPOP.CMS.Template;
using TRPOP.CMS.Model;
using System.Data;
using System.Collections;
using System.Text.RegularExpressions;
using TRPOP.CMS.Business;
using TRPOP.Config;

namespace TRPOP.CMS.Publish
{
    public class PublishHtml
    {

        /// <summary>
        /// 发布结点
        /// </summary>
        /// <param name="strNodeId"></param>
        /// <param name="intIndex"></param>
        /// <param name="intCountNum"></param>
        /// <returns></returns>
        public static bool PubNode(string strNodeId, int intIndex, int intCountNum, params object[] objParams)
        {
            bool blnReturn = false;
            NodeInfo oNodeInfo = new NodeManage().GetInfoById(strNodeId.ToInt());
            if (oNodeInfo == null)
                return false;
            for (int i = intIndex; i < intIndex + intCountNum; i++)
            {
                if (PublishAccess.PubOneNodeIndexPage(oNodeInfo, i) == false)
                {
                    if (intCountNum > 1 && i != intIndex)
                    {
                        blnReturn = true;
                    }
                    break;
                }
                else
                    blnReturn = true;
            }
            return blnReturn;
        }

        /// <summary>
        /// 附加发布
        /// </summary>
        /// <param name="strNodeIds"></param>
        /// <param name="intIndex"></param>
        /// <param name="intCountNum"></param>
        /// <returns></returns>
        public static bool PubExtra(string strNodeIds, int intIndex, int intCountNum, params object[] objParams)
        {
            NodeAddionalPubManage oNodeAddionalPubManage = new NodeAddionalPubManage();
            NodeAddionalPubInfo oNodeAddionalPubInfo = null;
            NodeInfo oNodeInfo = null;
            bool blnReturn = false;
            foreach (string strTemp in strNodeIds.Split(','))
            {
                oNodeAddionalPubInfo = oNodeAddionalPubManage.GetInfoById(strTemp.ToInt(0));
                if (oNodeAddionalPubInfo == null)
                    continue;
                oNodeInfo = (new NodeManage()).GetInfoById(oNodeAddionalPubInfo.NodeId);
                if (oNodeInfo == null)
                    continue;
                for (int i = 1; i <= intCountNum; i++)
                {
                    if (PublishAccess.PubOneNodeExtraPage(oNodeInfo, intIndex, oNodeAddionalPubInfo) == false)
                    {
                        if (intCountNum > 1 && i != intIndex)
                        {
                            blnReturn = true;
                        }
                        break;
                    }
                    else
                        blnReturn = true;
                }
                oNodeInfo = null;
                oNodeAddionalPubInfo = null;
            }
            return blnReturn;
        }

        /// <summary>
        /// 发布内容
        /// </summary>
        /// <param name="strContentids"></param>
        public static bool PubContent(string strContentids, params object[] objParams)
        {
            foreach (string strid in strContentids.Split(','))
            {
                PublishAccess.PubOneContentPage(strid.ToInt(0));
            }
            return true;
        }
    }
}
